package com.xzy.java.observer;

import lombok.extern.slf4j.Slf4j;

import java.util.Observable;
import java.util.Observer;

/**
 * Java自身对观察者模式的具体实现
 *
 * @author xzy.xiao
 * @date 2023/3/14  9:57
 */
@Slf4j
public class MyObserver implements Observer {
    /**
     * This method is called whenever the observed object is changed. An
     * application calls an <tt>Observable</tt> object's
     * <code>notifyObservers</code> method to have all the object's
     * observers notified of the change.
     *
     * @param o   the observable object.
     * @param arg an argument passed to the <code>notifyObservers</code>
     */
    @Override
    public void update(Observable o, Object arg) {
        log.info("观察到 {} 的状态发生改变 {}", o, arg);
    }
}
